package com.athuiju.hr.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 * 
 * </p>
 *
 * @author wzh
 * @since 2021-12-15
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="Sector对象", description="")
public class Sector implements Serializable,Comparable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty(value = "部门")
    private String sector;

    @ApiModelProperty(value = "部门id")
    private Integer sectorid;


    @ApiModelProperty(value = "状态")
    private Boolean isDisable;

    @ApiModelProperty(value = "父类目id,顶级类目填0")
    private String parentId;

    @ApiModelProperty(value = "是否为父节点，0为否，1为是")
    private Boolean isParent;

    @ApiModelProperty(value = "排序指数，越小越靠前")
    private Integer sort;

    @TableLogic
    @ApiModelProperty(value = "逻辑删除 1（true）已删除， 0（false）未删除")
    private Boolean isDeleted;


    @TableField(fill= FieldFill.INSERT_UPDATE)
    @ApiModelProperty(value = "最新更新时间")
    private Date  gmtCreate;


    @TableField(fill= FieldFill.INSERT_UPDATE)
    @ApiModelProperty(value = "最新更新时间")
    private Date gmtModified;



    @TableField(exist = false )
    public   Integer level;

    @TableField(exist = false )
    public ArrayList<Sector> children;

    @Override
    public int compareTo(Object o){
        if (o instanceof  Sector){
            Sector sector=(Sector)  o;
            //按照年龄升序排
            return  this.sort-sector.getSort();
            //return  this.name.compareTo(emp.getName());//姓名升序
        }
        throw  new ClassCastException("不能转化emp类型对象");
    }

}
